package com.lxw.study.structural.proxy.dynamicproxy.proxyfactory.advisor;

import com.lxw.study.structural.proxy.dynamicproxy.proxyfactory.advice.MyAfterReturningAdvice;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.PointcutAdvisor;
import org.springframework.aop.support.StaticMethodMatcherPointcut;

import java.lang.reflect.Method;

public class MyPointcutAdvisor implements PointcutAdvisor {
    @Override
    public Pointcut getPointcut() {
        return new StaticMethodMatcherPointcut() {
            @Override
            public boolean matches(Method method, Class<?> targetClass) {
                return "hello".equals(method.getName());
            }
        };
    }

    @Override
    public Advice getAdvice() {
        return new MyAfterReturningAdvice();
    }

    @Override
    public boolean isPerInstance() {
        return false;
    }
}
